package ig.util;

// SQL Utility Imports
import java.io.FileInputStream;
import java.io.IOException;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

//import sl314.util.sql.ConnectionPool;

public class InicializarConnectionPool implements Serializable {

    /*	private static final long serialVersionUID = 1L;

	public InicializarConnectionPool() throws IOException {
	   String FICHERO_CONFIGURACION1 = "ConnectionPoolDB.properties";
	   String FICHERO_CONFIGURACION2 = "ConnectionPoolDW.properties";
	    Properties propiedades1,propiedades2;
		String jdbcDriver = "";
	    String jdbcURL = "";
	    
	    try {
	      FileInputStream f1 = new FileInputStream(FICHERO_CONFIGURACION1);
	      FileInputStream f2 = new FileInputStream(FICHERO_CONFIGURACION2);
	      propiedades1 = new Properties();
	      propiedades2 = new Properties();
	      propiedades1.load(f1);
	      propiedades2.load(f2);
	      f1.close();
	      f2.close();
              
	      jdbcDriver = propiedades1.getProperty("jdbcDriver");
	      jdbcURL = propiedades1.getProperty("jdbcURL");
	      String jdbcUserName = propiedades1.getProperty("jdbcUserName");
	      String jdbcPassword = propiedades1.getProperty("jdbcPassword");
	      int minimumConnections = Integer.parseInt(propiedades1.getProperty("minimumConnections"));
	      int maximumConnections = Integer.parseInt(propiedades1.getProperty("maximumConnections"));
      
	      ConnectionPool connectionPool;

		  // Get a reference to the NamingService singleton
	      NamingService nameSvc = NamingService.getInstance();
	
		  // Create ConnectionPool object
	      connectionPool = new ConnectionPool(jdbcDriver,jdbcURL,jdbcUserName, jdbcPassword,minimumConnections,maximumConnections);
	      // Store the connection pool in the "application" scope.
	      nameSvc.setAttribute("connectionPool1", connectionPool);
	      
	      System.out.println("Connection pool 1 created for URL=" + jdbcURL);

		  jdbcDriver = propiedades2.getProperty("jdbcDriver");
	      jdbcURL = propiedades2.getProperty("jdbcURL");
	      jdbcUserName = propiedades2.getProperty("jdbcUserName");
	      jdbcPassword = propiedades2.getProperty("jdbcPassword");
	      minimumConnections = Integer.parseInt(propiedades2.getProperty("minimumConnections"));
	      maximumConnections = Integer.parseInt(propiedades2.getProperty("maximumConnections"));
      
		  // Get a reference to the NamingService singleton
		  // Create ConnectionPool object
	      connectionPool = new ConnectionPool(jdbcDriver,jdbcURL,jdbcUserName, jdbcPassword,minimumConnections,maximumConnections);
	
	      // Store the connection pool in the "application" scope.
	      nameSvc.setAttribute("connectionPool2", connectionPool);
	      
	      System.out.println("Connection pool 2 created for URL=" + jdbcURL);
	      
	      } catch (ClassNotFoundException cnfe) {
	    	  System.out.println("JDBC Driver class " + jdbcDriver
	                      + " no fue Encontrada."+ cnfe);

	       } catch (InstantiationException ie) {
	    	   System.out.println("JDBC Driver class " + jdbcDriver + " no pudo "
	                      + "crear un objecto."+ ie);

	       } catch (IllegalAccessException iae) {
	    	   System.out.println("JDBC Driver (" + jdbcDriver + ") class "
	                      + "nu fue inicializado o accesado."+ iae);

	       } catch (SQLException sex) {
	    	   System.out.println("Hubo un error creando el "
	                      + "Pool de Conexiones para " + jdbcURL+" "+sex);
	       }
   }

   public void Destroyed() {
      NamingService nameSvc = NamingService.getInstance();

      // Retrieve the connection pool from the naming service.
      ConnectionPool connectionPool
        = (ConnectionPool) nameSvc.getAttribute("connectionPool1");

      // Shutdown the connection pool.
      connectionPool.shutdown();

      System.out.println("Connection pool shutdown.");
   }*/
}